from django.db import models
import datetime
# Create your models here.
class user(models.Model):
    # 姓名
    name = models.CharField(max_length=200,null=True,blank=True)
    # 性别
    gender = models.PositiveSmallIntegerField(null=True,blank=True)
    # 联系电话
    phone_number = models.CharField(max_length=100,null=True,blank=True)
    # 身份证号码
    identify_number = models.CharField(max_length=18,null=True,blank=True)
    # 身份证正面照片
    identify_positive = models.CharField(max_length=100,null=True,blank=True)
    # 身份证反面照片
    identify_reverse = models.CharField(max_length=100,null=True,blank=True)
    # 身份证反面照片
    openid = models.CharField(max_length=50,null=True,blank=True)
    # 身份
    type = models.BooleanField(default=0)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class address(models.Model):
    # 房东Id
    user_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 地址
    address = models.CharField(max_length=200,null=True,blank=True)
    # 街道
    street = models.CharField(max_length=200, null=True, blank=True)
    # 社区
    community = models.CharField(max_length=200, null=True, blank=True)
    # 门牌号
    number = models.CharField(max_length=200, null=True, blank=True)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True,blank=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class rs_address(models.Model):
    # 地址Id
    address_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 房东Id
    user_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 房号
    Room_number = models.CharField(max_length=100,null=True,blank=True)
    # 房源状态
    type = models.BooleanField(default=0)
    # 户型
    doors = models.CharField(max_length=100,null=True,blank=True)
    # 面积
    area = models.CharField(max_length=100,null=True,blank=True)
    # 面积
    toward = models.CharField(max_length=100,null=True,blank=True)
    # 家具
    goodfurniture = models.CharField(max_length=100,null=True,blank=True)
    # 房源照片
    image = models.CharField(max_length=200,null=True,blank=True)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class guests(models.Model):
    # 房号Id
    room_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 房东Id
    landlord_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 起始日期
    start_rent = models.CharField(max_length=200,null=True,blank=True)
    # 到期日期
    end_rent = models.CharField(max_length=200,null=True,blank=True)
    # 租金
    rent = models.CharField(max_length=200,null=True,blank=True)
    # 合同
    contract = models.CharField(max_length=200,null=True,blank=True)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)
    # 用户id
    guests = models.ForeignKey(user,on_delete=models.PROTECT)

class bill(models.Model):
    # 房号Id
    room = models.ForeignKey(rs_address,on_delete=models.PROTECT,related_name='rooms')
    # 用户id
    guests_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 房东Id
    landlord_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 当月总费用
    all_cost = models.CharField(max_length=200, default=0, null=False)
    # 当月水费
    water_cost = models.CharField(max_length=200,default=0,null=False)
    # 当月电费
    electricity_cost = models.CharField(max_length=200,default=0,null=False)
    # 当月网费
    network_cost = models.CharField(max_length=200,default=0,null=False)
    # 起始日期
    start_time = models.CharField(max_length=200,null=False)
    # 到期日期
    end_time = models.CharField(max_length=200,null=False)
    # 是否收取
    type = models.BooleanField(default=0)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class financial(models.Model):
    # 用户id
    user_id = models.ForeignKey(user,on_delete=models.PROTECT)
    # 当月总费用
    on_month_cost = models.CharField(max_length=200, default=0, null=False)
    # 当月水费
    on_month_income = models.CharField(max_length=200,default=0,null=False)
    # 当月电费
    on_will_month_cost = models.CharField(max_length=200,default=0,null=False)
    # 当月网费
    on_will_month_income = models.CharField(max_length=200,default=0,null=False)
    # 起始日期
    date = models.CharField(max_length=200,null=False)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class menu(models.Model):
    # 菜单名
    auth_name = models.CharField(max_length=200,blank=True)
    #  路径
    path = models.CharField(max_length=200,blank=True)
    # 菜单id
    children_id = models.PositiveSmallIntegerField(null=True,blank=True)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class rs_user(models.Model):
    # 登录id
    username = models.CharField(max_length=200,blank=True)
    # 用户id
    user_id = models.ForeignKey(user,on_delete=models.PROTECT)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)

class rsuser(models.Model):
    # 登录id
    username = models.CharField(max_length=200,blank=True)
    # 用户id
    user = models.ForeignKey(user,on_delete=models.PROTECT)
    # 删除
    is_delete = models.BooleanField(default=0)
    # 字段更新时间
    updated_at = models.DateTimeField(auto_now=True)
    # 字段创建时间
    create_at = models.DateTimeField(default=datetime.datetime.now)